<template>
  <page-header-wrapper>
    <a-card :bordered="false">
      <s-table
        ref="table"
        size="default"
        :rowKey="(record, index) => index"
        :columns="columns"
        :data="loadData"
        :scroll="{ x: true }"
        :pagination="{ showTotal: (total) => `共 ${total} 条` }"
        :showPagination="false"
      >
        <span slot="index" slot-scope="text, record, index">{{ index + 1 }} </span>
        <ellipsis slot="ellipsis" slot-scope="text">{{ text || '/' }}</ellipsis>
        <span slot="empty" slot-scope="text">{{ text || '/' }}</span>
        <span slot="time" slot-scope="text">{{ text | moment }}</span>
      </s-table>
    </a-card>
  </page-header-wrapper>
</template>

<script>
import { STable, Ellipsis } from '@/components'
import { getStatementList } from '@/api/statementAndStatistics'
export default {
  components: {
    STable,
    Ellipsis
  },
  data () {
    return {
      queryParam: {
        Mode: 'SpecialCensus',
        UserID: this.$store.getters.userid,
        strContent: {}
      },
      columns: [
        { title: '类别', align: 'center', width: '80px', dataIndex: 'CATEGORY', fixed: 'left' },
        { title: '环卫工人', align: 'center', dataIndex: 'HWGR' },
        { title: '公交行业职工', align: 'center', dataIndex: 'GJHYZG' },
        { title: '60岁以上老年人', align: 'center', dataIndex: 'OLDPEOPLE' },
        { title: '未成年人', align: 'center', dataIndex: 'YOUNGPEOPLE' },
        { title: '残疾人', align: 'center', dataIndex: 'CJR' },
        { title: '优抚对象', align: 'center', dataIndex: 'YFDX' },
        { title: '农业转移人口', align: 'center', dataIndex: 'NYZYRK' },
        { title: '卫生行业职工', align: 'center', dataIndex: 'WSHYZG' },
        { title: '消防救援人员', align: 'center', dataIndex: 'XFJYRY' },
        { title: '退役军人', align: 'center', dataIndex: 'TYJR' },
        { title: '现役军人家属', align: 'center', dataIndex: 'XYJRJS' },
        { title: '农民工', align: 'center', dataIndex: 'NMG' },
        { title: '家政从业人员', align: 'center', dataIndex: 'JZCYRY' },
        { title: '劳模', align: 'center', dataIndex: 'LM' },
        { title: '省部级以上劳模家庭', align: 'center', dataIndex: 'SBJYSLMJT' },
        { title: '城市见义勇为人员家庭', align: 'center', dataIndex: 'CSJYYWRYJT' },
        { title: '教育行业职工', align: 'center', dataIndex: 'JYHYZG' },
        { title: '计划生育特殊困难家庭', align: 'center', dataIndex: 'JHSYTSKNJT' },
        { title: '建档立卡贫困户', align: 'center', dataIndex: 'JDLKPKH' }
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: (parameter) => {
        const requestParameters = Object.assign({}, parameter, this.queryParam)
        return getStatementList(requestParameters).then((res) => res)
      }
    }
  },
  methods: {
    tableRefresh (refresh = false) {
      this.$refs.table.refresh(refresh)
    }
  }
}
</script>
<style lang="less" scoped>
/deep/ .ant-table {
  td,
  tr {
    white-space: nowrap;
  }
}
</style>
